package com.logistics.modules.sys.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.logistics.modules.sys.entity.SystemcodetableEntity;
import com.logistics.modules.sys.service.SystemcodetableService;
import com.logistics.common.utils.PageUtils;
import com.logistics.common.utils.R;



/**
 * 
 *
 * @author HURRICANE
 * @email HURRICANE@nb.com
 * @date 2022-05-11 15:29:16
 */
@RestController
@RequestMapping("sys/systemcodetable")
public class SystemcodetableController {
    @Autowired
    private SystemcodetableService systemcodetableService;



    /**
     * 拿到运输计划的结算状态和计划状态和货物状态
     *
     * @return {@link List}<{@link SystemcodetableEntity}>
     */
    @RequestMapping("/getMoveStatus")
    @RequiresPermissions("transportationManagement:moveplan:list")
    public R getMoveStatus(){

        List<SystemcodetableEntity> planMoney = systemcodetableService.getListByPlanMoney();
        List<SystemcodetableEntity> planStatus = systemcodetableService.getListByPlanStatus();
        List<SystemcodetableEntity> planCargoStatus = systemcodetableService.getListByPlanCargoStatus();

        return R.ok().put("planMoney", planMoney).put("planStatus", planStatus).put("planCargoStatus", planCargoStatus);
    }


    /**
     *  获取所有的车辆运输订单的状态
     *
     * @return {@link List}<{@link SystemcodetableEntity}>
     */
    @RequestMapping("/getListByVehicleShippingOrderStatus")
    @RequiresPermissions("sys:systemcodetable:list")
    public R getListByVehicleShippingOrderStatus(){

        List<SystemcodetableEntity> list = systemcodetableService.getListByVehicleShippingOrderStatus();

        return R.ok().put("list", list);
    }

    /**
     * 根据logisticsLocation拿到所有分类
     *
     * @return {@link List}<{@link SystemcodetableEntity}>
     */
    @RequestMapping("/getListByLogisticsLocation")
    @RequiresPermissions("sys:systemcodetable:list")
    public R getListByLogisticsLocation(){

        List<SystemcodetableEntity> list = systemcodetableService.getListByLogisticsLocation();

        return R.ok().put("list", list);
    }

    /**
     * 根据客户订单状态拿到所有分类
     *
     * @return {@link List}<{@link SystemcodetableEntity}>
     */
    @RequestMapping("/getListByCliOrder")
    @RequiresPermissions("transportationManagement:clientorder:list")
    public R getListByCliOrder(){

        List<SystemcodetableEntity> list = systemcodetableService.getListByCliOrder();

        return R.ok().put("list", list);
    }

    /**
     * 根据货物单位拿到所有分类
     *
     * @return {@link List}<{@link SystemcodetableEntity}>
     */
    @RequestMapping("/getListByCargoUnit")
    @RequiresPermissions("sys:systemcodetable:list")
    public R getListByCargoUnit(){

        List<SystemcodetableEntity> list = systemcodetableService.getListByCargoUnit();

        return R.ok().put("list", list);
    }


    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys:systemcodetable:list")
    public R list(@RequestParam Map<String, Object> params){

        PageUtils page = systemcodetableService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("sys:systemcodetable:info")
    public R info(@PathVariable("id") Integer id){

		SystemcodetableEntity systemcodetable = systemcodetableService.getById(id);

        return R.ok().put("systemcodetable", systemcodetable);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("sys:systemcodetable:save")
    public R save(@RequestBody SystemcodetableEntity systemcodetable){

		systemcodetableService.save(systemcodetable);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("sys:systemcodetable:update")
    public R update(@RequestBody SystemcodetableEntity systemcodetable){

		systemcodetableService.updateById(systemcodetable);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("sys:systemcodetable:delete")
    public R delete(@RequestBody Integer[] ids){

		systemcodetableService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
